package com.kd.enums.employee;

/**
 * 权限等级枚举
 */
public enum PermissionLevel {
    NORMAL(0, "普通权限"),
    FINANCE(1, "财务权限"),
    EXECUTIVE(2, "高层权限");

    private final Integer code;
    private final String desc;

    PermissionLevel(Integer code, String desc) {
        this.code  = code;
        this.desc  = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取枚举
     */
    public static PermissionLevel getByCode(Integer code) {
        for (PermissionLevel level : values()) {
            if (level.code.equals(code))  {
                return level;
            }
        }
        throw new IllegalArgumentException("无效权限码: " + code);
    }
}